package model.entity.role;

import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import model.entity.Orders;
import model.entity.Voucher;
import model.entity.product.Suggestion;

@Entity
@Table(name = "Users", uniqueConstraints = {
		@UniqueConstraint(columnNames = "Username"),
		@UniqueConstraint(columnNames = "Email") })
public class Users {

	private int userId;
	private GroupRole groupRole;
	private String fullName;
	private String username;
	private String email;
	private String pass;
	private String address;
	private String phone;
	private Boolean vip;
	private List<Orders> orders = new ArrayList<Orders>(0);
	private List<Voucher> vouchers = new ArrayList<Voucher>(0);
	private List<Suggestion> suggestions = new ArrayList<Suggestion>(0);

	public Users() {
	}

	public Users(GroupRole groupRole, String fullName,
			String username, String email, String pass, String address,
			String phone) {
		this.groupRole = groupRole;
		this.fullName = fullName;
		this.username = username;
		this.email = email;
		this.pass = pass;
		this.address = address;
		this.phone = phone;
	}

	public Users(GroupRole groupRole, String fullName,
			String username, String email, String pass, String address,
			String phone, Boolean vip, List<Orders> orders, List<Voucher> vouchers,
			List<Suggestion> suggestions) {
		this.groupRole = groupRole;
		this.fullName = fullName;
		this.username = username;
		this.email = email;
		this.pass = pass;
		this.address = address;
		this.phone = phone;
		this.vip = vip;
		this.orders = orders;
		this.vouchers = vouchers;
		this.suggestions = suggestions;
	}

	@Id
	@GeneratedValue(generator = "User_ID_Gen", strategy = GenerationType.IDENTITY)
	@SequenceGenerator(name = "User_ID_Gen", sequenceName = "User_SEQ_ID")
	@Column(name = "UserID", unique = true, nullable = false)
	public int getUserId() {
		return this.userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "RoleID", nullable = false)
	public GroupRole getGroupRole() {
		return this.groupRole;
	}

	public void setGroupRole(GroupRole groupRole) {
		this.groupRole = groupRole;
	}

	@Column(name = "FullName", nullable = false)
	public String getFullName() {
		return this.fullName;
	}

	public void setFullName(String fullName) {
		this.fullName = fullName;
	}

	@Column(name = "Username", unique = true, nullable = false)
	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Column(name = "Email", unique = true, nullable = false)
	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Column(name = "Pass", nullable = false)
	public String getPass() {
		return this.pass;
	}

	public void setPass(String pass) {
		this.pass = pass;
	}

	@Column(name = "Address", nullable = false)
	public String getAddress() {
		return this.address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@Column(name = "Phone", nullable = false)
	public String getPhone() {
		return this.phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	@Column(name = "VIP")
	public Boolean getVip() {
		return this.vip;
	}

	public void setVip(Boolean vip) {
		this.vip = vip;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
	public List<Orders> getOrders() {
		return this.orders;
	}

	public void setOrders(List<Orders> orders) {
		this.orders = orders;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
	public List<Voucher> getVouchers() {
		return this.vouchers;
	}

	public void setVouchers(List<Voucher> vouchers) {
		this.vouchers = vouchers;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
	public List<Suggestion> getSuggestions() {
		return this.suggestions;
	}

	public void setSuggestions(List<Suggestion> suggestions) {
		this.suggestions = suggestions;
	}

}
